این کد جای نمایش پیغام پیشفرض از کد میگیره.

<script>
jQuery(document).ready(function ($) {
  const filterButtonsHTML = `
    <div id="sigmaweb-review-filters" style="margin-bottom: 15px;">
        <button class="sigmaweb-filter-btn active" data-rating="all">همه دیدگاه‌ها</button>
        <button class="sigmaweb-filter-btn" data-rating="buyers">فقط خریداران</button>
    </div>
  `;

  // حذف پیام پیش‌فرض ووکامرس
  $(".woocommerce-noreviews").remove();

  // اضافه کردن دکمه‌ها بالای نظرات
  $("#comments .woocommerce-Reviews-title").after(filterButtonsHTML);

  // ایجاد پیام مخفی
  if ($("#sigmaweb-no-comments-message").length === 0) {
    $("#comments").append(
      '<p id="sigmaweb-no-comments-message" style="display:none;"></p>'
    );
  }

  // اگر در ابتدا هیچ نظری نیست و دکمه همه فعال است، پیام نمایش داده شود
  if ($(".commentlist li").length === 0) {
    $("#sigmaweb-no-comments-message")
      .text("نظری برای این محصول ثبت نشده.")
      .show();
  }

  // کلیک روی دکمه‌ها
  $(document).on("click", ".sigmaweb-filter-btn", function () {
    var rating = $(this).data("rating");

    $(".sigmaweb-filter-btn").removeClass("active");
    $(this).addClass("active");

    $("#sigmaweb-no-comments-message").hide();
    $(".commentlist li").hide();

    if (rating === "all") {
      $(".commentlist li").show();

      if ($(".commentlist li").length === 0) {
        $("#sigmaweb-no-comments-message")
          .text("نظری برای این محصول ثبت نشده.")
          .show();
      }
    } else if (rating === "buyers") {
      var filtered = $(".commentlist li").filter(function () {
        return $(this).find(".woocommerce-review__verified.verified").length > 0;
      });

      if (filtered.length > 0) {
        filtered.show();
      } else {
        $("#sigmaweb-no-comments-message")
          .text("خریداران نظری ثبت نکرده‌اند.")
          .show();
      }
    }
  });
});
</script>
